import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;

public class Controller {

    // View and simulator that handles the information
    private View view;
    private Simulator simulator;

    public Controller (View view, Simulator simulator)
    {
        this.view=view;
        this.simulator=simulator;
    }

   /**
     * Creates events for buttons,
     * that will be executed after clicking on the buttons.
     */
    public void buttonEvents() {
        view.getStepOne().addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                simulator.stop();
                simulator.simulateOneStep();
             }});
        view.getStepHundred().addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                simulator.simulate(100);
                simulator.stop();
             }});
        view.getPlaySimulation().addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
               simulator.start();
             }});
        view.getStopSimulation().addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                simulator.stop();
             }});
        view.getReset().addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                simulator.stop();
                simulator.reset();
             }});
    }
}